package com.app.ryjy.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 用工形式枚举
 */
@AllArgsConstructor
@Getter
public enum EmploymentFormEnum {
    // 原固定职工
    ORIGINAL_FIXED_WORKER("原固定职工", 1, -1),
    // 城镇合同制
    URBAN_CONTRACT_SYSTEM("城镇合同制", 2, -1),
    // 农村合同制
    RURAL_CONTRACT_SYSTEM("农村合同制", 3, -1),
    // 临时工
    TempoRARY_WORKER("临时工", 4, -1),
    // 聘任制
    APPOINTMENT_SYSTEM("聘任制", 5, -1),
    // 其他
    OTHER("其他", 9, -1);

    private final String desc;
    private final int code;
    private final int bizCode;

    /**
     * 根据 bizCode 获取 code
     *
     * @param bizCode bizCode
     * @return code
     */
    public static int getCodeByBizCode(int bizCode) {
        for (EmploymentFormEnum form : values()) {
            if (form.getBizCode() == bizCode) {
                return form.getCode();
            }
        }
        throw new RuntimeException("bizCode 不存在");
    }

    public static void main(String[] args) {
        System.out.println(EmploymentFormEnum.getCodeByBizCode(1));
    }
}